import { View, Text, Button } from '@tarojs/components'
import Taro, {
  useLoad,
  useDidShow,
  useDidHide,
  useReady,
  useUnload,
  usePullDownRefresh,
  useReachBottom,
  useShareAppMessage,
  usePageScroll,
} from '@tarojs/taro'
import './index.scss'

export default function Index() {
  // 页面加载完成 onLoad
  useLoad((query) => {
    console.log('Page loaded.', query)
  })
  // 页面 显示 onShow
  useDidShow(() => {})
  // 页面 隐藏 onHide
  useDidHide(() => {})
  // 页面 渲染完成 onReady
  useReady(() => {})
  // 页面 卸载 onUnload
  useUnload(() => {})
  // 页面下拉刷新的回调
  usePullDownRefresh(() => {
    console.log('usePullDownRefresh')
  })
  // 上拉触底的回调
  useReachBottom(() => {
    console.log('useReachBottom')
  })
  // 分享给朋友的回调
  useShareAppMessage(() => {
    return {
      title: '标题',
    }
  })
  usePageScroll(() => {
    console.log('usePageScroll')
  })

  function jumpAbout() {
    Taro.navigateTo({
      url: '/pages/about/index?id=100&name=张三',
    })
  }

  return (
    <View className='index'>
      <Text>Hello world!</Text>

      <Button onClick={jumpAbout}>jump About</Button>
      <View style={{ height: 1000 }}></View>
    </View>
  )
}
